/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.fxbank.netbeans.plugins.utils;

import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

/**
 *
 * @author alexey
 */
public class SAXHandler extends DefaultHandler {

    private ArrayList<String> xng;
    private boolean queryElem = false;

    public String[] getXNG() {
        return xng.toArray(new String[xng.size()]);
    }

    @Override
    public void characters(char[] chars, int i, int i1) throws SAXException {
        super.characters(chars, i, i1);
        if (queryElem) {
            
        }
    }

    @Override
    public void endDocument() throws SAXException {
        super.endDocument();
    }

    @Override
    public void endElement(String string, String string1, String string2) throws SAXException {
        super.endElement(string, string1, string2);
        queryElem = false;
    }

    @Override
    public void startDocument() throws SAXException {
        super.startDocument();
        xng = new ArrayList<String>();
    }

    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        if ("query".equalsIgnoreCase(qName)) {
            queryElem = true;
        }
    }
}
